{% set pypi_name = 'oslo.middleware' %}
{% set upstream_version = upstream_version('4.1.1') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack oslo.middleware library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('Jinja2') }}
BuildRequires:  {{ py3('WebOb') }}
BuildRequires:  {{ py3('debtcollector') }}
BuildRequires:  {{ py3('devel') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.context') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('statsd') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('stevedore') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
Oslo middleware library includes components that can be injected into wsgi
pipelines to intercept request/response flows. The base class can be enhanced
with functionality like add/delete/modification of http headers and support
for limiting size/connection etc.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack oslo.middleware library
Requires:       {{ py3('Jinja2') }}
Requires:       {{ py3('WebOb') }}
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.context') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('statsd') }}
Requires:       {{ py3('stevedore') }}

%description -n {{ py2name(py_versions='py3') }}
Oslo middleware library includes components that can be injected into wsgi
pipelines to intercept request/response flows. The base class can be enhanced
with functionality like add/delete/modification of http headers and support
for limiting size/connection etc.

This package contains the Python 3.x module.

%package -n {{ py2name(py_versions='py3') }}-doc
Summary:        Documentation for OpenStack middleware library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n {{ py2name(py_versions='py3') }}-doc
Oslo middleware library includes components that can be injected into wsgi
pipelines to intercept request/response flows. The base class can be enhanced
with functionality like add/delete/modification of http headers and support
for limiting size/connection etc.
This package contains the documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%py3_build

# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%py3_install

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst ChangeLog
%{python3_sitelib}/oslo_middleware
%{python3_sitelib}/*.egg-info

%files -n {{ py2name(py_versions='py3') }}-doc
%license LICENSE
%doc doc/build/html

%changelog
